import { Component, OnInit } from '@angular/core';
import { Product, productService } from '../shared/product.service';
import { FormControl } from '@angular/forms';
import 'rxjs/Rx';
import { Observable } from 'rxjs';
@Component({
  selector: 'app-product',
  templateUrl: './product.component.html',
  styleUrls: ['./product.component.css']
})
export class ProductComponent implements OnInit {
  products:Observable<Product[]>;
  //定义查询关键字
  keyword:string;
  //筛选期
  filter:FormControl = new FormControl();
  constructor(public productservice:productService) {
    this.filter.valueChanges
    .debounceTime(500)
    .subscribe(
      value => {this.keyword = value;console.log(this.keyword)}
    )
  }

  ngOnInit() {
    this.products = this.productservice.getProducts();
  }
}
